<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">

<h:head></h:head>
<body>
	<h:panelGroup id="panelGroupVideogame" layout="block">
		<!-- Listar Videogame -->
		<p:panel id="painelListarVideogame" widgetVar="painelListarVideogame"
			visible="true" closable="true" closeSpeed="0" style="border: none">
			<h:form id="formListarVideogame">
				<p:commandLink action="#{videogameBean.limparVideogame}"
					update=":formIncluirVideogame"
					oncomplete="PF('painelListarVideogame').close(); PF('painelIncluirVideogame').show();">
					<h:outputText value="Incluir Videogame" />
				</p:commandLink>
				<p:dataTable style="width: 50%;" value="#{videogameBean.videogames}"
					var="videogame" emptyMessage="" id="tableUsu" paginator="true"
					rows="7"
					paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
					rowsPerPageTemplate="7,14,21">

					<p:column>
						<f:facet name="header">
							<h:outputText value="Código" />
						</f:facet>
						<h:outputText value="#{videogame.id}" />
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="Plataforma" />
						</f:facet>
						<h:outputText value="#{videogame.plataforma.nome}" />
					</p:column>
					<p:column>
						<p:commandButton value="Consultar"
							update=":formConsultarVideogame"
							oncomplete="PF('painelConsultarVideogame').show(); PF('painelListarVideogame').close();">
							<f:setPropertyActionListener target="#{videogameBean.videogame}"
								value="#{videogame}"></f:setPropertyActionListener>
						</p:commandButton>
					</p:column>
					<p:column>
						<p:commandButton value="Alterar" update=":formAlterarVideogame" action="#{videogameBean.listarPlataforma}"
							oncomplete="PF('painelAlterarVideogame').show(); PF('painelListarVideogame').close();">
							<f:setPropertyActionListener target="#{videogameBean.videogame}"
								value="#{videogame}"></f:setPropertyActionListener>
						</p:commandButton>
					</p:column>
					<p:column>
						<p:commandButton value="Excluir"
							action="#{videogameBean.excluirVideogame}"
							update=":formListarVideogame">
							<f:setPropertyActionListener target="#{videogameBean.videogame}"
								value="#{videogame}"></f:setPropertyActionListener>
							<p:confirm header=""
								message="Tem certeza que deseja efetuar esta exclusão ?"
								icon="ui-icon-alert" />
						</p:commandButton>
					</p:column>
				</p:dataTable>
			</h:form>
		</p:panel>

		<!-- Incluir Videogame -->
		<p:panel id="painelIncluirVideogame"
			widgetVar="painelIncluirVideogame" visible="false" closable="true"
			closeSpeed="0" style="border: none">
			<h:form id="formIncluirVideogame">
				<p:panel style="width: 50%;">
					<table>
						<tr>
							<td><h:outputLabel value="Plataforma:" /></td>
							<td><h:selectOneMenu value="#{videogameBean.plataforma.id}">
									<f:selectItem itemLabel="Selecione" itemValue="" />
									<f:selectItems value="#{videogameBean.plataformas}"
										var="plataforma" itemLabel="#{plataforma.nome}"
										itemValue="#{plataforma.id}" />
								</h:selectOneMenu></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Referência do Modelo: " /></td>
							<td><p:inputText
									value="#{videogameBean.videogame.referenciaModelo}" /></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Disponibilidade: " /></td>
							<td><p:inputText
									value="#{videogameBean.videogame.disponibilidade}" /></td>
						</tr>
					</table>
				</p:panel>
				<div class="posicao_botao" align="right">
					<p:commandButton value="Voltar"
						onclick="PF('painelIncluirVideogame').close(); PF('painelListarVideogame').show();"
						type="button" />
					<p:commandButton value="Enviar"
						action="#{videogameBean.incluirVideogame}" styleClass="botao"
						update=":formListarVideogame"
						oncomplete="PF('painelIncluirVideogame').close(); PF('painelListarVideogame').show();" />
				</div>
			</h:form>
		</p:panel>

		<!-- Alterar Videogame -->
		<p:panel id="painelAlterarVideogame"
			widgetVar="painelAlterarVideogame" visible="false" closable="true"
			closeSpeed="0" style="border: none">
			<h:form id="formAlterarVideogame">
				<p:panel style="width: 50%;">
					<table>
						<tr>
							<td><h:outputLabel value="Plataforma:" /></td>
							<td><h:selectOneMenu value="#{videogameBean.videogame.plataforma.id}">
									<f:selectItem itemLabel="Selecione" itemValue="" />
									<f:selectItems value="#{videogameBean.plataformas}"
										var="plataforma" itemLabel="#{plataforma.nome}"
										itemValue="#{plataforma.id}" />
								</h:selectOneMenu></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Referência do Modelo: " /></td>
							<td><p:inputText
									value="#{videogameBean.videogame.referenciaModelo}" /></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Disponibilidade: " /></td>
							<td><p:inputText
									value="#{videogameBean.videogame.disponibilidade}" /></td>
						</tr>
					</table>
				</p:panel>

				<div class="posicao_botao" align="right">
					<p:commandButton value="Voltar" update=":formListarVideogame"
						onclick="PF('painelAlterarVideogame').close(); PF('painelListarVideogame').show();"
						type="button" />
					<p:commandButton value="Enviar" id="botao"
						action="#{videogameBean.atualizarVideogame}" styleClass="botao"
						update=":formListarVideogame"
						oncomplete="PF('painelAlterarVideogame').close(); PF('painelListarVideogame').show();" />
				</div>
			</h:form>
		</p:panel>

		<!-- Consultar Videogame -->
		<p:panel id="painelConsultarVideogame"
			widgetVar="painelConsultarVideogame" visible="false" closable="true"
			closeSpeed="0" style="border: none">
			<h:form id="formConsultarVideogame">
				<p:panel style="width: 50%;">
					<table border="1" class="tableConsulta" cellpadding="10">
						<tr>
							<td><h:outputLabel value="Código:" /></td>
							<td><h:outputLabel value="#{videogameBean.videogame.id}" /></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Referência do Modelo: " /></td>
							<td><h:outputLabel
									value="#{videogameBean.videogame.referenciaModelo}" /></td>
						</tr>
						<tr>
							<td><h:outputLabel value="Disponibilidade: " /></td>
							<td><h:outputLabel
									value="#{videogameBean.videogame.disponibilidade}" /></td>
						</tr>
					</table>

				</p:panel>
				<div class="posicao_botao" align="right">
					<p:commandButton value="Voltar"
						onclick="PF('painelConsultarVideogame').close(); PF('painelListarVideogame').show();"
						type="button" />
				</div>
			</h:form>
		</p:panel>
	</h:panelGroup>
</body>
</html>
